package com.szpx.mapper;

import com.szpx.entity.XWY.denglu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 用户登录数据访问接口
 */
@Mapper
public interface dengluMapper {
    
    /**
     * 根据用户名查询用户
     * @param username 用户名
     * @return 用户信息
     */
    @Select("SELECT * FROM denglu WHERE username = #{username}")
    denglu selectByUsername(@Param("username") String username);
    
    /**
     * 根据ID更新用户信息
     * @param user 用户信息
     * @return 影响的行数
     */
    @Update("<script>" +
            "UPDATE denglu " +
            "<set>" +
            "  <if test='password != null'>password = #{password},</if>" +
            "  <if test='name != null'>name = #{name},</if>" +
            "  <if test='phone != null'>phone = #{phone},</if>" +
            "  <if test='role != null'>role = #{role},</if>" +
            "  <if test='status != null'>status = #{status},</if>" +
            "  <if test='lastLoginTime != null'>last_login_time = #{lastLoginTime},</if>" +
            "</set>" +
            "WHERE id = #{id}" +
            "</script>")
    int updateById(denglu user);
}